<template>
	<view class="page">
		<nav-bar :title="'日常' + _typeName" leftArrow>
			<template #right>
				<van-icon @click="goLink('created')" name="add-o" size="25" />
			</template>
		</nav-bar>

		<List :type="path.type" />
	</view>
</template>

<script setup>
	import {
		ref,
		computed
	} from 'vue';

	import List from './components/List';

	const path = defineProps({
		type: String, // 1维修 2养护
	});

	const _typeName = computed(() => {
		const typeMap = {
			'1': '维修',
			'2': '养护',
		};
		window.document.title = '日常' + (typeMap[path.type] || '');
		return typeMap[path.type] || '';
	});

	const goLink = (option, id) => {
		switch (option) {
			case 'created':
				uni.navigateTo({
					url: `/pages/dailyFix/created?type=${path.type}`
				})
				break;
			default:
				uni.navigateTo({
					url: `/pages/dailyFix/detail?type=${path.type}&id=${id}&state=${option}`
				})
				break;
		}
	}
</script>

<style lang="scss" scoped>
</style>